﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Configuration;
using System.Security.Cryptography;

namespace DusonFramework.Core.Security
{
    public class HashAlgorithmProvider<T> : ICryptographyProvider where T: HashAlgorithm, new ()
    {
        private T _provider = new T();

        #region Public Methods

        public string Encrypting(string source)
        {
            if (string.IsNullOrEmpty(source))
                throw new InvalidOperationException("There is no encrypting target. ");

            byte[] bSource = Encoding.UTF8.GetBytes(source);
            byte[] bHash = _provider.ComputeHash(bSource);

            return BitConverter.ToString(bHash);
        }

        public string Decrypting(string source)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
